package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.HysRoom;
import com.ruoyi.system.service.IHysRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * zzController
 *
 * @author ruoyi
 * @date 2025-09-25
 */
@RestController
@RequestMapping("/system/room")
public class HysRoomController extends BaseController {

    @Autowired
    private IHysRoomService hysRoomService;





    /**
     * 查询zz列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(HysRoom hysRoom) {
        startPage();
        List<HysRoom> list = hysRoomService.selectHysRoomList(hysRoom);
        return getDataTable(list);
    }

    /**
     * 导出zz列表
     */
    @Log(title = "zz", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HysRoom hysRoom) {
        List<HysRoom> list = hysRoomService.selectHysRoomList(hysRoom);
        ExcelUtil<HysRoom> util = new ExcelUtil<HysRoom>(HysRoom.class);
        util.exportExcel(response, list, "zz数据");
    }

    /**
     * 获取zz详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(hysRoomService.selectHysRoomById(id));
    }

    /**
     * 新增zz
     */
    @Log(title = "zz", businessType = BusinessType.INSERT)
    @PreAuthorize("@ss.hasPermi('system:room:add')")
    @PostMapping
    public AjaxResult add(@RequestBody HysRoom hysRoom) {
        return toAjax(hysRoomService.insertHysRoom(hysRoom));
    }

    /**
     * 修改zz
     */
    @Log(title = "zz", businessType = BusinessType.UPDATE)
    @PreAuthorize("@ss.hasPermi('system:room:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody HysRoom hysRoom) {
        return toAjax(hysRoomService.updateHysRoom(hysRoom));
    }

    /**
     * 删除zz
     */
    @Log(title = "zz", businessType = BusinessType.DELETE)
    @PreAuthorize("@ss.hasPermi('system:room:remove')")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(hysRoomService.deleteHysRoomByIds(ids));
    }


}
